package com.hxzy.shop.member.controller;

import com.github.pagehelper.PageInfo;
import com.hxzy.shop.member.dto.MemberGrowUp.req.GrowUpValueReq;
import com.hxzy.shop.member.dto.MemberGrowUp.resp.GrowUpValueResp;
import com.hxzy.shop.member.dto.member.req.MemberDetailsReq;
import com.hxzy.shop.member.dto.member.req.MemberListsReq;
import com.hxzy.shop.member.dto.member.resp.MemberDetailResp;
import com.hxzy.shop.member.dto.member.resp.MemberLabelResp;
import com.hxzy.shop.member.dto.member.resp.MemberListsResp;
import com.hxzy.shop.member.service.LabelService;
import com.hxzy.shop.member.service.MemberService;
import com.hxzy.shop.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author admin
 * @Desc
 * @Date 2023/8/3
 */
@Api(tags = "会员中心")
@RestController
@RequestMapping("/member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    @Autowired
    private LabelService labelService;

    /**
     * 查看会员- 会员列表
     *
     * @param req 会员列表请求体
     * @return 查询的会员列表
     */
    @ApiOperation("会员列表")
    @PostMapping(value = "/memberLists")
    public Result<PageInfo<MemberListsResp>> memberLists(@RequestBody MemberListsReq req){
        return Result.success(memberService.memberLists(req));
    }

    /**
     * 查看会员- 会员详细
     *
     * @param req 会员详细请求体
     * @return 会员详细信息
     */
    @ApiOperation(value = "会员详情")
    @PostMapping(value = "/memberDetails")
    public Result<MemberDetailResp> memberDetails(@RequestBody @Validated MemberDetailsReq req){
        return Result.success(memberService.memberDetails(req));
    }

    /**
     * 成长值
     *
     * @param req 成长值请求
     * @return 会员成长值
     */
    @ApiOperation(value = "会员详细-成长值记录")
    @PostMapping("/getMemberGrowUp")
    public Result<PageInfo<GrowUpValueResp>> getMemberGrowUp(GrowUpValueReq req){
        return Result.success(memberService.getMemberGrowUp(req));
    }

    /**
     * 会员标签列表
     *
     * @param req memberDetailsReq
     * @return 会员标签
     */
    @ApiOperation(value = "会员标签列表")
    @PostMapping(value = "/getMemberLabel")
    public Result<List<MemberLabelResp>> getMemberLabel(@RequestBody MemberDetailsReq req){
        return Result.success(labelService.getMemberLabel(req));
    }
}
